#pragma once

#include "Connection.h"
#include <string>
#include <Windows.h>
#include <WinSock.h>
using std::string;

class TCPPoint
{
public:
	TCPPoint(void);
	~TCPPoint(void);

	bool CreateSocket();
	bool Listen(string ip, int port);
	bool Connect(string ip, int port);
	Connection Accept();
	Connection GetConnection();
	void Close();

	string GetErrorMessage();
private:
	int _sock;
	int _backlog;
	Connection _connection;
	bool _socketCreated;
	string _errorMessgae;

	bool bindSocket(string ip, int port);
	Connection setConnection(int sock, sockaddr_in remoteAddr);
};
